package com.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Description:
 * Copyright:   Copyright (c)2019
 * Company:     zefu
 *
 * @author: 张李鑫
 * @version: 1.0
 * Create at:   2022-02-18 16:32:17
 * <p>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2022-02-18     张李鑫                     1.0         1.0 Version
 */
public class Poll {

    public AtomicInteger atomicInteger = new AtomicInteger();

    public static  final Map map=new HashMap();

    public static void main(String[] args) {
        new Thread(()->{
            System.out.println(Thread.currentThread().getName());
        },"thread1").run();
        new Thread(()->{
            System.out.println(Thread.currentThread().getName());
        },"thread12").run();
        System.out.println(123);
    }

    public ThreadPoolExecutor createThread() {
        return new ThreadPoolExecutor(2,
                10,
                5,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(10), this::createThread, new ThreadPoolExecutor.DiscardPolicy());

    }


    public Thread createThread(Runnable runnable) {
        Thread thread = new Thread(runnable);
        thread.setName("自定义线程" + atomicInteger.incrementAndGet());
        return thread;
    }
}
